package com.service.impl;
    
    


import $pkType;
import $entityType;
import com.service.ProductService;
import com.repository.ProductRepository;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;


/**
 * 业务层
 *
 * @author makejava
 * @since 2025-01-04 00:23:42
 */
@Service
public class ProductServiceImpl implements ProductService {

	@Resource
    private ProductRepository productRepository;

    @Override
    public void save(Product product) {
        productRepository.save(product);
    }

    @Override
    public void deleteById(Integer id) {
        productRepository.delete(id);
    }

    @Override
    public Product findById(Integer id) {
        return productRepository.findOne(id);
    }

    @Override
    public List<Product> findById(Collection<Integer> ids) {
        Iterable<Product> iterable = productRepository.findAll(ids);
        return StreamSupport.stream(iterable.spliterator(), false)
                .collect(Collectors.toList());
    }

    @Override
    public Page<Product> list(Pageable page) {
        return productRepository.findAll(page);
    }

}

